package com.sinosoft.builder.utils;

import com.sinosoft.builder.templates.concept.AssociationConceptBetweenDomainConceptsType;
import com.sinosoft.builder.templates.concept.BehaviorConceptType;
import com.sinosoft.builder.templates.concept.EntityConceptType;
import com.sinosoft.builder.templates.concept.RoleConceptType;

/**
 * 业务概念领域类型
 * 
 * @author 潘巍（PeterPan）
 * @since 2011-5-20 下午03:29:32
 * 
 */
public enum BusinessConceptDomainType {
	// 业务概念-实体概念模型
	BUSSINESSCONCEPT_ENTITY(EntityConceptType.class, "entity"),

	// 业务概念-角色概念模型
	BUSSINESSCONCEPT_ROLE(RoleConceptType.class, "role"),

	// 业务概念-行为概念模型
	BUSSINESSCONCEPT_BEHAVIOR(BehaviorConceptType.class, "behavior"),

	// 业务概念-关联领域概念模型
	BUSSINESSCONCEPT_ASSOCIATIONCONCEPTDOMAIN(
			AssociationConceptBetweenDomainConceptsType.class, "assodomain");

	BusinessConceptDomainType(Class<?> domainClass, String relativePath) {
		this.domainClass = domainClass;
		this.relativePath = relativePath;
	}

	// 领域概念类对象
	private Class<?> domainClass;

	// 领域存储的相对路径
	private String relativePath;

	public Class<?> getDomainClass() {
		return domainClass;
	}

	public void setDomainClass(Class<?> domainClass) {
		this.domainClass = domainClass;
	}

	public String getRelativePath() {
		return relativePath;
	}

	public void setRelativePath(String relativePath) {
		this.relativePath = relativePath;
	}

	/**
	 * 通过元数据对象的获得领域类型
	 * 
	 * @param o
	 * @return
	 */
	public static BusinessConceptDomainType getDomainType(Object o) {
		if (o != null)
			for (BusinessConceptDomainType type : BusinessConceptDomainType
					.values()) {
				if (o.getClass() == type.getDomainClass()) {
					return type;
				}
			}
		return null;
	}

}
